package com.joysuch.wwyt.edu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joysuch.wwyt.edu.bean.EduCertListDto;
import com.joysuch.wwyt.edu.entity.WwytEduCertificateUser;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author pp
 * @since 2021-04-15
 */
public interface WwytEduCertificateUserMapper extends BaseMapper<WwytEduCertificateUser> {

    IPage<EduCertListDto> getCertsList(Page<EduCertListDto> page, Long userId, Integer userContractorFlag, Integer useState, Integer certificateStatus, Long certId,String userNameOrCertNo,String userNameOrUserCode,String certNo);

    IPage<EduCertListDto> getContractStaffCertsList(Page<EduCertListDto> page, Long userId, Integer userContractorFlag, Integer useState, Integer certificateStatus, Long certId,String userNameOrCertNo,String userNameOrUserCode,String certNo);

    IPage<EduCertListDto> getCertsListByUseStateAndCertificateStatus(Page<EduCertListDto> page, Integer useState, Integer certificateStatus, Long certId,String userNameOrCertNo,String userNameOrUserCode,String certNo);

    /**
     *
     * @param page         page
     * @param tenentId     tenentId
     * @param orgCode      orgCode
     * @param nameOrCode   姓名或者工号
     * @param ids          权限范围内的承包商单位的ids
     * @param userContractorFlag 人员/承包商人员flag 0: 人员; 1 承包商人员
     * @param certNo       证书编号
     * @param certIds      证书类型下的证书id或者证书id的ids
     * @param certificateStatus 证书状态
     * @param effectQueryStartTime  证书有效开始时间
     * @param effectQueryEndTime    证书有效结束范围
     * @param reviewQueryStartTime  证书复审开始时间
     * @param reviewQueryEndTime    证书复审结束时间
     * @param certStatus 证书有效状态
     * @return
     */
    Page<WwytEduCertificateUser> selectUserCertPageByAuth(Page page ,Long tenentId, String orgCode, String nameOrCode,Set<Long> ids , Boolean userContractorFlag ,
                                                          String certNo , List<Long> certIds, Integer certificateStatus , Date effectQueryStartTime , Date effectQueryEndTime ,
                                                          Date reviewQueryStartTime ,Date reviewQueryEndTime ,String certStatus);

    /**
     *
     * @param page         page
     * @param tenentId     tenentId
     * @param orgCode      orgCode
     * @param nameOrCode   姓名或者工号
     * @param ids          权限范围内的承包商单位的ids
     * @param userContractorFlag 人员/承包商人员flag 0: 人员; 1 承包商人员
     * @param certNo       证书编号
     * @param certIds      证书类型下的证书id或者证书id的ids
     * @param certificateStatus 证书状态
     * @param effectQueryStartTime  证书有效开始时间
     * @param effectQueryEndTime    证书有效结束范围
     * @param reviewQueryStartTime  证书复审开始时间
     * @param reviewQueryEndTime    证书复审结束时间
     * @param certStatus 证书有效状态
     * @return
     */
    Page<WwytEduCertificateUser> selectContractorCertPageByAuth(Page page ,Long tenentId, String orgCode, String nameOrCode,Set<Long> ids , Boolean userContractorFlag ,
        String certNo , List<Long> certIds, Integer certificateStatus , Date effectQueryStartTime , Date effectQueryEndTime ,
                                                                Date reviewQueryStartTime ,Date reviewQueryEndTime,String certStatus );

    /**
     * 查找到期的证书
     * @param endTime  到期时间
     * @param certStatus  证书有效状态 -1到期
     * @return
     */
    List<WwytEduCertificateUser> findCertificates(@Param("endTime") Date endTime, @Param("certStatus") String certStatus);

    /**
     * 查询待有效证书
     *
     * @param date
     * @param certStatus
     * @return
     */
    List<WwytEduCertificateUser> findFutureCertificates(@Param("tokenTime") Date date, @Param("certStatus") String certStatus);
}
